import java.io.*;
import java.net.*; 
import java.awt.*;
import javax.swing.*;

public class PokkeriKlient extends JApplet implements Runnable{
   BufferedReader br;
   PrintWriter pw;
   JTextArea ta=new JTextArea();
   public static final long serialVersionUID=1;
   public PokkeriKlient(){
     add(new JLabel("Saabuvad andmed"), BorderLayout.NORTH);
	 add(ta);
	 try{
			ta.append("Proovib\n");
			Socket sc=new Socket("greeny.cs.tlu.ee", 3000);
			br = new BufferedReader(new InputStreamReader(sc.getInputStream()));
			pw = new PrintWriter(sc.getOutputStream(), true);
			pw.println("Toomas");
			ta.append("avanes\n");
			new Thread(this).start();
	 }catch (Exception ex){
	 
	  ta.append(ex.getMessage());
	 
	 }
   }
   
   public void run(){
   
	try{
	
		String rida= br.readLine();
		while(rida != null){
		
			ta.append(rida+"\n");
			rida = br.readLine();
		
		}
	
	}catch(Exception ex){
	
	ta.append(ex.getMessage());
	
	}
   
   }
}